﻿using DeviceCommons.DeviceMessages.Abstractions;
using DeviceCommons.DeviceMessages.Models;
using DeviceCommons.DeviceMessages.Serialization.V1.Serializers;
using System.Buffers;

namespace DeviceCommons.DeviceMessages.Serialization.V2.Serializers
{
    public class DeviceMessageHeaderSerializer : AbstractMessageSerializer<IDeviceMessageHeader>, IDeviceMessageHeaderSerializer
    {
        public DeviceMessageHeaderSerializer() : base(new DeviceMessageHeader())
        {
        }

        private readonly static int HEADERLENGTH = 4;
        public override void Serializer(ArrayBufferWriter<byte> writer, IDeviceMessageHeader model)
        {
            writer.Write(model.Header);
            writer.Write([model.Version]);
            writer.Write([model.Mark]);
        }
    }
}
